package com.cxrj.zhsq.housePropertyManage.controller;


import java.io.IOException;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.cxrj.zhsq.housePropertyManage.entity.PropertyOwner;
import com.cxrj.zhsq.housePropertyManage.service.PropertyOwnerService;

@RestController
public class PropertyOwnerController {
	@Resource
	private PropertyOwnerService propertyOwnerService;
	
	/**
	 * 添加业主
	 * @param propertyOwner
	 * @param request
	 * @return
	 */
	@RequestMapping("insertOwner")
	public Map<String, Object> insertOwner(PropertyOwner propertyOwner,HttpServletRequest request){
		return propertyOwnerService.insertOwner(propertyOwner,request);
	}
	
	/**
	 * 查询所有
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("selectOwnerList")
	public Map<String, Object> selectOwnerList(HttpServletRequest request,HttpServletResponse response){
		return propertyOwnerService.selectOwnerList(request,response);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@RequestMapping("deleteOwner")
	public Map<String, Object> deleteOwner(PropertyOwner propertyOwner){
		return propertyOwnerService.deleteOwner(propertyOwner);
	}
	
	/**
	 *详情
	 * @param id
	 * @return
	 */
	@RequestMapping("selectOwnerDetails")
	public Map<String, Object> selectOwnerDetails(String id){
		return propertyOwnerService.selectOwnerDetails(id);
	}
	/**
	 * 修改
	 * @param propertyOwner
	 * @return
	 */
	@RequestMapping("updateOwner")
	public Map<String, Object> updateOwner(PropertyOwner propertyOwner,HttpServletRequest request){
		return propertyOwnerService.updateOwner(propertyOwner,request);
	}
	
	/**
	 * 导入
	 * @param file
	 * @param request
	 * @return
	 */
	@RequestMapping("insertOwnerList")
	public Map<String, Object> insertOwnerList(@RequestParam(value="file") MultipartFile file,HttpServletRequest request) throws IOException{
		return propertyOwnerService.insertOwnerList(file,request);
	}
	
}
